#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <QVBoxLayout>
#include <QCheckBox>

#include "CommunicationInfo.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void setUsername(QString);
    void open();
    void transmitAndSerializeMessage(const CommunicationInfo &info);
    void receivedAndDeserializeMessage(CommunicationInfo &info);
    void CommunicationInfoCout(CommunicationInfo &info);
    void CommunicationInit(CommunicationInfo &info);
     void on_btnReload_clicked();
    //xlx20240521
    QString onCheckBoxStateChanged();
     void creatbyneed(QByteArray data);
signals:
    // void startConnect(QString, unsigned short);
    // void sendFile(QString);

private slots:

    void onReadyRead();

    void check_socket();

    void on_btnUser_clicked();

    void on_btnUpload_clicked();

    void on_btnOk_clicked();

    void on_btnDownLoad_clicked();

    //void on_btnReload_clicked();

    void on_btnShare_clicked();

    void on_btnDelete_clicked();

    void refresh_return();

    char * my_strtok(char * string, const char * control);

    char * my_strtok_origin(char * string, const char * control, char * * tmp_str);

    void on_newRe_clicked();

private:
    Ui::MainWindow *ui;
    QTcpSocket *socket;
    QString uploadFileName;
    QString uploadFilenameWithoutPath;
    QString downloadFileName;
    QString username;
    CommunicationInfo receivedInfo;
    CommunicationInfo transmitInfo;
    QTimer myTimer;
    int flagi;
    int flag_readyRead;
};
#endif // MAINWINDOW_H
